package cn.flant.io.tcp;

import java.io.IOException;
import java.net.Socket;
import java.nio.charset.Charset;

public abstract class MessageHandler {
	private Charset charset;

	public Charset getCharset() {
		return charset;
	}

	public void setCharset(Charset charset) {
		if (charset == null) {
			charset = Charset.defaultCharset();
		}
		this.charset = charset;
	}

	public abstract void onConnected(Socket socket) throws IOException;

	public abstract Object readMessage() throws IOException;

	public abstract void sendMessage(Object message) throws IOException;

	public abstract void onClosed();

}
